home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / compiler / mips / subprim.lisp < prev    next >
Encoding:
Text File  |  1991-11-06  |  1.9 KB  |  66 lines

  1. ;;; -*- Package: MIPS; Log: C.Log -*-
  2. ;;;
  3. ;;; **********************************************************************
  4. ;;; This code was written as part of the CMU Common Lisp project at
  5. ;;; Carnegie Mellon University, and has been placed in the public domain.
  6. ;;; If you want to use this code or any part of CMU Common Lisp, please contact
  7. ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
  8. ;;;
  9. (ext:file-comment
  10.   "$Header: subprim.lisp,v 1.20 91/02/20 15:15:14 ram Exp $")
  11. ;;;
  12. ;;; **********************************************************************
  13. ;;;
  14. ;;; $Header: subprim.lisp,v 1.20 91/02/20 15:15:14 ram Exp $
  15. ;;;
  16. ;;;    Linkage information for standard static functions, and random vops.
  17. ;;;
  18. ;;; Written by William Lott.
  19. ;;; 
  20. (in-package "MIPS")
  21.  
  22.  
  23.  
  24. ;;;; Length
  25.  
  26. (define-vop (length/list)
  27.   (:translate length)
  28.   (:args (object :scs (descriptor-reg) :target ptr))
  29.   (:arg-types list)
  30.   (:temporary (:scs (descriptor-reg) :from (:argument 0)) ptr)
  31.   (:temporary (:scs (non-descriptor-reg) :type random) temp)
  32.   (:temporary (:scs (any-reg) :type fixnum :to (:result 0) :target result)
  33.           count)
  34.   (:results (result :scs (any-reg descriptor-reg)))
  35.   (:policy :fast-safe)
  36.   (:vop-var vop)
  37.   (:save-p :compute-only)
  38.   (:generator 50
  39.     (let ((done (gen-label))
  40.       (loop (gen-label))
  41.       (not-list (generate-cerror-code vop object-not-list-error object)))
  42.       (move ptr object)
  43.       (move count zero-tn)
  44.  
  45.       (emit-label loop)
  46.  
  47.       (inst beq ptr null-tn done)
  48.       (inst nop)
  49.  
  50.       (simple-test-simple-type ptr temp not-list t vm:list-pointer-type)
  51.  
  52.       (loadw ptr ptr vm:cons-cdr-slot vm:list-pointer-type)
  53.       (inst addu count count (fixnum 1))
  54.       (simple-test-simple-type ptr temp loop nil vm:list-pointer-type)
  55.  
  56.       (cerror-call vop done object-not-list-error ptr)
  57.  
  58.       (emit-label done)
  59.       (move result count))))
  60.        
  61.  
  62. (define-static-function length (object) :translate length)
  63.  
  64.  
  65.  
  66.